
import type { EnterpriseDetail, GetParkEnterpriseData, GetParkEnterpriseParams, GetRentList, GetRentListInterface, Industry, ParkEnterPriseData, PostParkEnterprise, PostParkEnterpriseRentParams, PostUpload, putParkEnterprise } from "@/types/park"
import { request, requestBlob } from "@/utils/reuqest"



// 园区管理-获取企业列表
export const getParkEnterprise = (params:GetParkEnterpriseParams) =>{
    return request<ParkEnterPriseData>('/park/enterprise','GET',params)
}

// 园区管理-增加企业
export const AddParkEnterprise = (data:PostParkEnterprise) =>{
    return request('/park/enterprise','POST',data)
}

// 查询企业所属行业
export const GetParkIndustry = () =>{
    return request<Industry[]>('/park/industry','GET')
}

// 上传文件接口
export const PostUploadAPI = (fd:FormData) =>{
    return request<PostUpload>('/upload','POST',fd)
}

// 查看企业（数据回显）
export const GetParkEnterpriseAPI = (id:string) =>{
    return request<GetParkEnterpriseData>(`/park/enterprise/${id}`)
}

// 编辑企业
export const PutParkEnterprise = (data:putParkEnterprise) =>{
    return request('/park/enterprise','PUT',data)
}

// 删除企业
export const DeleteEnterprise = (id:string) => {
    return request(`/park/enterprise/${id}`,'DELETE')
}

// 查询可租赁楼宇
export const GetRentListAPI = () =>{
    return request<GetRentList[]>('/park/rent/building')
}

// 添加/续租 企业的租赁合同
export const PostParkEnterpriseRentAPI = (data:PostParkEnterpriseRentParams)=>{
    return request('/park/enterprise/rent','POST',data)
} 

// 获取租赁的合同列表
export const GetParkRentListAPI = (id:string) =>{
    return request<GetRentListInterface[]>(`/park/enterprise/rent/${id}`,'GET')
}

// 退租租赁合同
export const PutExitRent = (id:string) =>{
    return request(`/park/enterprise/rent/${id}`,'PUT')
}

// 删除租赁合同
export const DeleteEnterpriseRent = (id:string) =>{
    return request(`/park/enterprise/rent/${id}`,'DELETE')
}

// 查看企业详情
export const getEnterpriseDetailAPI = (id:string) =>{
    return request<EnterpriseDetail>(`/park/enterprise/${id}`)
}

// 下载合同
export const downloadFileAPI = (id: string) => {
  return requestBlob(`/download/${id}`, 'GET');
};